Telegram Group & Telegram Channel
ℹ️ Как компьютеры находят простые числа в тысячи раз быстрее, чем ты на бумажке

📌 Что делает решето Эратосфена

Находит все простые числа от 1 до N — быстро, эффективно и без перебора делителей.

➡️ Как это работает

▪️ Создаём массив от 2 до N

▪️ Берём первое невычеркнутое число p

▪️ Вычеркиваем все кратные p

▪️ Переходим к следующему невычеркнутому числу

▪️ Повторяем, пока p² <= N

Пример на Python:
def eratosthenes(n):
sieve = [True] * (n+1)
sieve[0:2] = [False, False]
for i in range(2, int(n**0.5) + 1):
if sieve[i]:
for j in range(i*i, n+1, i):
sieve[j] = False
return [i for i, prime in enumerate(sieve) if prime]


🔵 Чтобы знать об алгоритмах все, забирайте наш курс «Алгоритмы и структуры данных»

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2771
Create:
Last Update:

ℹ️ Как компьютеры находят простые числа в тысячи раз быстрее, чем ты на бумажке

📌 Что делает решето Эратосфена

Находит все простые числа от 1 до N — быстро, эффективно и без перебора делителей.

➡️ Как это работает

▪️ Создаём массив от 2 до N

▪️ Берём первое невычеркнутое число p

▪️ Вычеркиваем все кратные p

▪️ Переходим к следующему невычеркнутому числу

▪️ Повторяем, пока p² <= N

Пример на Python:

def eratosthenes(n):
sieve = [True] * (n+1)
sieve[0:2] = [False, False]
for i in range(2, int(n**0.5) + 1):
if sieve[i]:
for j in range(i*i, n+1, i):
sieve[j] = False
return [i for i, prime in enumerate(sieve) if prime]


🔵 Чтобы знать об алгоритмах все, забирайте наш курс «Алгоритмы и структуры данных»

Proglib Academy #буст

BY Proglib.academy | IT-курсы




Share with your friend now:
tg-me.com/proglib_academy/2771

View MORE
Open in Telegram


Proglib academy | IT курсы Telegram | DID YOU KNOW?

Date: |

NEWS: Telegram supports Facetime video calls NOW!

Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Proglib academy | IT курсы from tw


Telegram Proglib.academy | IT-курсы
FROM USA